package com.atguigu.agent.config;

import com.atguigu.agent.store.MongoChatMemoryStore;
import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SeparateChatAssitantConfig {
    @Autowired
    private MongoChatMemoryStore mongoChatMemoryStore;

    @Bean
    public ChatMemoryProvider chatMemoryProvider(){
         return memoryId -> MessageWindowChatMemory
                 .builder()
                 .id(memoryId)
                 .maxMessages(10)
                 .chatMemoryStore(mongoChatMemoryStore)
                 .build();

//创建了一个自动注入memoryId的ChatMemory对象，以chatmemoryprovider的形式提供给智能体。
    }
}
